package nowcoder.written_examination.wangyi;

import java.util.HashSet;
import java.util.Scanner;

/**
 * @author fance
 * @date 18-6-30 上午10:20
 */
public class MainII {
    private static int cnt = 0;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            String[] a = new String[n];
            for (int i = 0; i < n; i++) {
                a[i] = scanner.next();
            }
            backtracing(a,0,new HashSet<>());
            System.out.println(cnt);
        }
    }
    public static void backtracing(String[] a, int index, HashSet<Integer> set){
        if (index >= a.length) {
            cnt++;
            return;
        }
        String cur = a[index];
        for (int i = 0; i < cur.length(); i++) {
            int work = cur.charAt(i) - '0';
            if (!set.contains(work)) {
                set.add(work);
                backtracing(a,index + 1,set);
                set.remove(work);
            }
        }
    }
}
   /* public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String s = scanner.next();
            int n = scanner.nextInt();
            System.out.println(fun(s,n));
        }
    }
    public static int fun(String s,int n) {
        int res = 0;
        if (s.contains("X")) {
            int i = s.indexOf("X");
            String tmp = s.substring(0,i);
            for (int j = 0; j < 10; j++) {
                String tmptmp =  tmp + j + s.substring(i + 1);
                res += fun(tmptmp,n);
            }
        } else {
             if (new BigInteger(s).mod(new BigInteger(String.valueOf(n))).equals(new BigInteger("0"))) {
            res = 1;
            }
        }
        return res;
    }
}*/
    /*public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int m = scanner.nextInt();
            Set<String> mine = new HashSet<>();
            Set<String> sys = new HashSet<>();
            for (int i = 0; i < n; i++) {
                mine.add(scanner.next());
            }
            for (int i = 0; i < m; i++) {
                sys.add(scanner.next());
            }
            int res = 0;
            for (String cur : mine) {
                if (ext(cur,sys)) {
                    res += cur.length() * cur.length();
                }
            }
            System.out.println(res);
        }
    }
    private static boolean ext(String s, Set<String> sys) {
        for (String cur : sys) {
            if (cur.equals(s)) {
                return true;
            }
        }
        return false;
    }
}*/
    /*public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            String[] a = new String[n];
            for (int i = 0; i < n; i++) {
                a[i] = scanner.next();
            }
            int max = 0;
            for (int i = 0; i < n; i++) {
                StringBuilder stringBuilder = new StringBuilder();
                for (int j = 0; j < n; j++) {
                   stringBuilder.append(a[j].charAt(i));
                }
                int maxArea = 0;
                String cur = stringBuilder.toString();
                int curArea = 1;
                for (int j = 0; j < cur.length() - 1; j++) {
                    if (cur.charAt(j) == cur.charAt(j + 1)) {
                        curArea++;
                        maxArea = Math.max(curArea,maxArea);
                    } else {
                        curArea = 1;
                        maxArea = Math.max(curArea,maxArea);
                    }
                }
                max = Math.max(max,maxArea);
            }
            System.out.println(max);
        }
    }
}*/
    /*public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String s = scanner.nextLine();

            System.out.println(cal(s.trim()));
        }
    }
    public static int cal(String s) {
        int res = 0;
            int i = 0;
            while (s.charAt(i) != '+' ||
                    s.charAt(i) != '-' ||
                    s.charAt(i) != '*') {
                i++;
            }
            if (i == s.length()) {
                res =  Integer.parseInt(s);
            } else {
                char op = s.charAt(i);
                switch (op) {
                    case '+':
                        res =  cal(s.substring(0, i)) + cal(s.substring(i + 1)); break;
                    case '-':
                        res =  cal(s.substring(0, i)) - cal(s.substring(i + 1)); break;
                    case '*':
                        res =  cal(s.substring(0, i)) * cal(s.substring(i + 1)); break;
                }
            }
            return res;
    }
}*/
   /* public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int w = scanner.nextInt();
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            int z = scanner.nextInt();
            Set<Integer> set = new HashSet<>();
//            List<Integer> list = new ArrayList<>();
            for (int i = w; i <= x; i++) {
                for (int j = y; j <= z; j++) {
                    set.add(i / j);
                }
            }
            System.out.println(set.size());
        }
    }
}*/

   /* public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    while (scanner.hasNext()) {
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
        for (int i = 0; i < k; i++) {
            fun(a);
        }
        for (int i = 0; i < n; i++) {
            if (i == n - 1) {
                System.out.print(a[i]);
            } else {
                System.out.print(a[i] + " ");
            }
        }
    }

    }
    public static void fun(int[] a) {
        int first = a[0];
        for (int i = 0; i < a.length - 1; i++) {
            a[i] = (a[i] + a[i + 1]) >= 100 ? (a[i] + a[i + 1]) % 100 : (a[i] + a[i + 1]);
        }
        a[a.length - 1] = (a[a.length - 1] + first) >= 100 ? (a[a.length - 1] + first) % 100 : (a[a.length - 1] + first);
    }

}*/
   /* public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = scanner.nextInt();
            }
            List<Integer> list = new ArrayList<>();
            for (int i = n - 1; i >= 0; i--) {
                if (!list.contains(a[i])) {
                    list.add(a[i]);
                }
            }
            Collections.reverse(list);
            for (int i = 0; i < list.size(); i++) {
                if (i == list.size() - 1) {
                    System.out.print(list.get(i));
                } else {
                    System.out.print(list.get(i) + " ");
                }
            }
        }
    }
}*/
   /* public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String s = scanner.next();
            char[] a1 = s.toCharArray();
            char[] a2 = s.toCharArray();
            System.out.println(Math.min(bubbleSortI(a1,a1.length),bubbleSortII(a2,a2.length)));
        }
    }
    public static int bubbleSortI(char[] a, int n) {
        int res = 0;
        boolean flag = true;
        for (int i = 1; i < n && flag; i++) {
            flag = false;
            for (int j = 0; j < n - i; j++) {
                if (a[j] > a[j + 1]){
                    res++;
                    flag = true;
                    swap(a, j, j + 1);
                }
            }
        }
        return res;
    }
    public static int bubbleSortII(char[] a, int n) {
        int res = 0;
        boolean flag = true;
        for (int i = 1; i < n && flag; i++) {
            flag = false;
            for (int j = 0; j < n - i; j++) {
                if (a[j] < a[j + 1]){
                    res++;
                    flag = true;
                    swap(a, j, j + 1);
                }
            }
        }
        return res;
    }
    public static void swap(char[] a, int i, int j) {
        char tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
    }
}*/
    /*public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
//            int[] a = new int[n];
            long sum = 0;
            for (int i = 0; i < n; i++) {
                sum += scanner.nextInt() / 1024;
            }
            long res = 0;
            res = sum / 2;
            if (sum % 2 != 0) {
                res++;
            }
            System.out.println(res * 1024);
        }
    }*/

